package com.ybkj.chat.module.login.activity;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;
import com.ybkj.chat.module.login.presenter.PhoneCodeLoginPresenter;
import com.ybkj.chat.module.login.view.PhoneCodeLoginView;
import com.ybkj.chat.ui.view.ClearEditText;
import com.ybkj.chat.utils.VerificationCodeUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * author : ywh
 * date : 2019/2/5 13:08
 * description :手机验证码登录
 */
public class PhoneCodeLoginActivity extends BaseMvpActivity<PhoneCodeLoginPresenter> implements PhoneCodeLoginView {
    //登录账号
    @BindView(R.id.et_account)
    ClearEditText etAccount;
    //验证码
    @BindView(R.id.register_phone_code_et)
    EditText registerPhoneCodeEt;
    //获取注册验证码
    @BindView(R.id.register_code_btn)
    TextView registerCodeBtn;
    //登录
    @BindView(R.id.login_btn)
    Button loginBtn;
    //微信登录
    @BindView(R.id.wechat_login)
    ImageView wechatLogin;
    //qq登录
    @BindView(R.id.qq_login)
    ImageView qqLogin;

    @Override
    protected void injectPresenter() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_phone_login;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }


    @OnClick({R.id.register_code_btn, R.id.login_btn, R.id.wechat_login, R.id.qq_login, R.id.tv_password_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //获取验证码
            case R.id.register_code_btn:
                String phone = etAccount.getText().toString().trim();
                presenter.getPhoneCode(phone);
                break;
            //登录
            case R.id.login_btn:
                String phone1 = etAccount.getText().toString().trim();
                String code = registerPhoneCodeEt.getText().toString().trim();
                presenter.login(phone1, code);
                break;
            //微信登录
            case R.id.wechat_login:
                break;
            //qq登录
            case R.id.qq_login:
                break;
            //密码登录
            case R.id.tv_password_login:
                finish();
                break;
        }
    }

    @Override
    public boolean isImmersiveStatusBar() {
        return true;
    }

    @Override
    public void CodeSuccess() {
        VerificationCodeUtil util = new VerificationCodeUtil();
        util.codeCountDown(registerCodeBtn);
    }
}
